package books.ThinkingInJava.src.Chapter18;


import books.ThinkingInJava.src.Tools.FileKit;

import java.io.*;

/**
 * @author bloodcolding
 * @since 12/28/2018 4:32 PM
 */
public class RedirectStandardStream {
    public static void main(String[] arg) throws IOException {
        PrintStream printStream = System.out;
        String path1 = FileKit.filePathTransfer("D:\\Doc\\Test\\test.txt");
        String path2 = FileKit.filePathTransfer("D:\\Doc\\Test\\1.txt");
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(path2));
        PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(path2)));
        BufferedInputStream in = new BufferedInputStream(new FileInputStream(path1));
        System.setIn(in);
        System.setOut(out);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String s = null;
        while ((s = bufferedReader.readLine()) != null) {
            System.out.println(s);
        }
    }
}

